home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / GAS211S2.ZIP / src / gas-211 / include / coff / mips.h < prev    next >
C/C++ Source or Header  |  1993-05-30  |  6KB  |  186 lines

  1. /* Rudimentary ECOFF support on MIPS machines. 
  2.    This lacks symbol information, normally provided on MIPS Unix systems
  3.    in the files <sym.h> and <symconst.h>.  */
  4.  
  5. /********************** FILE HEADER **********************/
  6.  
  7. struct external_filehdr {
  8.   unsigned char f_magic[2];    /* magic number            */
  9.   unsigned char f_nscns[2];    /* number of sections        */
  10.   unsigned char f_timdat[4];    /* time & date stamp        */
  11.   unsigned char f_symptr[4];    /* file pointer to symtab    */
  12.   unsigned char f_nsyms[4];    /* number of symtab entries    */
  13.   unsigned char f_opthdr[2];    /* sizeof(optional hdr)        */
  14.   unsigned char f_flags[2];    /* flags            */
  15. };
  16.  
  17.  
  18. /* Mips magic numbers used in filehdr.  MIPS_MAGIC_LITTLE is used on
  19.    little endian machines.  MIPS_MAGIC_BIG is used on big endian
  20.    machines.  Where is MIPS_MAGIC_1 from?  */
  21. #define MIPS_MAGIC_1 0x0180
  22. #define MIPS_MAGIC_LITTLE 0x0162
  23. #define MIPS_MAGIC_BIG 0x0160
  24.  
  25. #define ECOFFBADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \
  26.             ((x).f_magic!=MIPS_MAGIC_LITTLE) &&\
  27.             ((x).f_magic!=MIPS_MAGIC_BIG))
  28.  
  29.  
  30. #define    FILHDR    struct external_filehdr
  31. #define    FILHSZ    20
  32.  
  33. /********************** AOUT "OPTIONAL HEADER" **********************/
  34.  
  35.  
  36. typedef struct external_aouthdr
  37. {
  38.   unsigned char magic[2];    /* type of file                */
  39.   unsigned char    vstamp[2];    /* version stamp            */
  40.   unsigned char    tsize[4];    /* text size in bytes, padded to FW bdry*/
  41.   unsigned char    dsize[4];    /* initialized data "  "        */
  42.   unsigned char    bsize[4];    /* uninitialized data "   "        */
  43.   unsigned char    entry[4];    /* entry pt.                */
  44.   unsigned char text_start[4];    /* base of text used for this file */
  45.   unsigned char data_start[4];    /* base of data used for this file */
  46.   unsigned char bss_start[4];    /* base of bss used for this file */
  47.   unsigned char gprmask[4];    /* ?? */
  48.   unsigned char cprmask[4][4];    /* ?? */
  49.   unsigned char gp_value[4];    /* value for gp register */
  50. } AOUTHDR;
  51.  
  52. /* compute size of a header */
  53.  
  54. #define AOUTSZ (sizeof(AOUTHDR))
  55.  
  56. #define ZMAGIC          0413    /* demand load format, eg normal ld output */
  57.  
  58. /********************** SECTION HEADER **********************/
  59.  
  60. struct external_scnhdr {
  61.   unsigned char    s_name[8];    /* section name            */
  62.   unsigned char    s_paddr[4];    /* physical address, aliased s_nlib */
  63.   unsigned char    s_vaddr[4];    /* virtual address        */
  64.   unsigned char    s_size[4];    /* section size            */
  65.   unsigned char    s_scnptr[4];    /* file ptr to raw data for section */
  66.   unsigned char    s_relptr[4];    /* file ptr to relocation    */
  67.   unsigned char    s_lnnoptr[4];    /* file ptr to line numbers    */
  68.   unsigned char    s_nreloc[2];    /* number of relocation entries    */
  69.   unsigned char    s_nlnno[2];    /* number of line number entries*/
  70.   unsigned char    s_flags[4];    /* flags            */
  71. };
  72.  
  73. #define    SCNHDR    struct external_scnhdr
  74. #define    SCNHSZ    sizeof(SCNHDR)
  75.  
  76. /*
  77.  * names of "special" sections
  78.  */
  79. #define _TEXT   ".text"
  80. #define _DATA   ".data"
  81. #define _BSS    ".bss"
  82. #define _RDATA    ".rdata"
  83. #define _SDATA    ".sdata"
  84. #define _SBSS    ".sbss"
  85. #define _LIT4    ".lit4"
  86. #define _LIT8    ".lit8"
  87. #define _LIB    ".lib"
  88.  
  89. #define DEFAULT_DATA_SECTION_ALIGNMENT 4
  90. #define DEFAULT_BSS_SECTION_ALIGNMENT 4
  91. #define DEFAULT_TEXT_SECTION_ALIGNMENT 16
  92. /* For new sections we havn't heard of before */
  93. #define DEFAULT_SECTION_ALIGNMENT 4
  94.  
  95. /* MIPS ECOFF uses some additional section types.  */
  96. #define STYP_RDATA 0x100
  97. #define STYP_SDATA 0x200
  98. #define STYP_SBSS 0x400
  99. #define STYP_LIT8 0x8000000
  100. #define STYP_LIT4 0x10000000
  101.  
  102. /* I don't know when this is used.  */
  103. #define STYP_OTHER_LOAD 0x80000000
  104.  
  105. /********************** RELOCATION DIRECTIVES **********************/
  106.  
  107. struct external_reloc {
  108.   unsigned char r_vaddr[4];
  109.   unsigned char r_bits[4];
  110. };
  111.  
  112. #define RELOC struct external_reloc
  113. #define RELSZ 8
  114.  
  115. /* MIPS ECOFF uses a packed 8 byte format for relocs.  These constants
  116.    are used to unpack the r_bits field.  */
  117.  
  118. #define RELOC_BITS0_SYMNDX_SH_LEFT_BIG        16
  119. #define RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE    0
  120.  
  121. #define RELOC_BITS1_SYMNDX_SH_LEFT_BIG        8
  122. #define RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE    8
  123.  
  124. #define RELOC_BITS2_SYMNDX_SH_LEFT_BIG        0
  125. #define RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE    16
  126.  
  127. #define RELOC_BITS3_TYPE_BIG            0x1E
  128. #define RELOC_BITS3_TYPE_SH_BIG            1
  129. #define RELOC_BITS3_TYPE_LITTLE            0x78
  130. #define RELOC_BITS3_TYPE_SH_LITTLE        3
  131.  
  132. #define RELOC_BITS3_EXTERN_BIG            0x01
  133. #define RELOC_BITS3_EXTERN_LITTLE        0x80
  134.  
  135. /* We store the extern field in the r_offset field of a struct
  136.    internal_reloc.  FIXME: Do this more sensibly.  */
  137. #define r_extern r_offset
  138.  
  139. /* If the extern bit is 1, then r_symndx is an index into the external
  140.    symbol table.  If the extern bit is 0, then r_symndx indicates a
  141.    section, and is one of the following values.  */
  142. #define RELOC_SECTION_TEXT    1
  143. #define RELOC_SECTION_RDATA    2
  144. #define RELOC_SECTION_DATA    3
  145. #define RELOC_SECTION_SDATA    4
  146. #define RELOC_SECTION_SBSS    5
  147. #define RELOC_SECTION_BSS    6
  148. #define RELOC_SECTION_INIT    7
  149. #define RELOC_SECTION_LIT8    8
  150. #define RELOC_SECTION_LIT4    9
  151.  
  152. /* The r_type field is one of the following values.  I don't know if
  153.    any other values can appear.  These seem to be all that occur in
  154.    the Ultrix 4.2 libraries.  */
  155. #define ECOFF_R_IGNORE    0
  156. #define ECOFF_R_REFHALF    1
  157. #define ECOFF_R_REFWORD    2
  158. #define ECOFF_R_JMPADDR    3
  159. #define ECOFF_R_REFHI    4
  160. #define ECOFF_R_REFLO    5
  161. #define ECOFF_R_GPREL    6
  162. #define ECOFF_R_LITERAL    7
  163.  
  164. /********************** STABS **********************/
  165.  
  166. /* gcc uses mips-tfile to output type information in special stabs
  167.    entries.  These must match the corresponding definition in
  168.    gcc/config/mips.h.  At some point, these should probably go into a
  169.    shared include file, but currently gcc and gdb do not share any
  170.    directories. */
  171. #define CODE_MASK 0x8F300
  172. #define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
  173. #define MIPS_MARK_STAB(code) ((code)+CODE_MASK)
  174. #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK)
  175. #define STABS_SYMBOL "@stabs"
  176.  
  177. /********************** COFF **********************/
  178.  
  179. /* gcc also uses mips-tfile to output COFF debugging information.
  180.    These are the values it uses when outputting the .type directive.
  181.    These should also be in a shared include file.  */
  182. #define N_BTMASK    (017)
  183. #define N_TMASK        (060)
  184. #define N_BTSHFT    (4)
  185. #define N_TSHIFT    (2)
  186.